{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数据探索\n",
    "test.csv: 测试数据(用户点击歌曲表)\n",
    "    id\n",
    "    msno: 用户id，加密String\n",
    "    song_id: song id，歌曲id\n",
    "    source_system_tab: 触发事件的类型/tab，用于表示app的功能类型\n",
    "    source_screen_name: 用户看到的布局的名字（name of the layout）\n",
    "    source_type: 用户在app上播放音乐的入口的类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "dpath = './data/'\n",
    "#读入测试数据\n",
    "test_data=pd.read_csv(dpath +'test.csv')\n",
    "song=pd.read_csv(dpath +'songs.csv')\n",
    "members=pd.read_csv(dpath +'members.csv')\n",
    "extra=pd.read_csv(dpath +'song_extra_info.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "test song dataset dimensions: (2556790, 6)\n"
     ]
    }
   ],
   "source": [
    "print(\"test song dataset dimensions:\", test_data.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2555994, 20)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#表合成一个总的data\n",
    "data = pd.merge(test_data,members,on=(\"msno\"))\n",
    "data = pd.merge(data,song,on=(\"song_id\"))\n",
    "data = pd.merge(data,extra,on=(\"song_id\"))\n",
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>msno</th>\n",
       "      <th>song_id</th>\n",
       "      <th>source_system_tab</th>\n",
       "      <th>source_screen_name</th>\n",
       "      <th>source_type</th>\n",
       "      <th>city</th>\n",
       "      <th>bd</th>\n",
       "      <th>gender</th>\n",
       "      <th>registered_via</th>\n",
       "      <th>registration_init_time</th>\n",
       "      <th>expiration_date</th>\n",
       "      <th>song_length</th>\n",
       "      <th>genre_ids</th>\n",
       "      <th>artist_name</th>\n",
       "      <th>composer</th>\n",
       "      <th>lyricist</th>\n",
       "      <th>language</th>\n",
       "      <th>name</th>\n",
       "      <th>isrc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>V8ruy7SGk7tDm3zA51DPpn6qutt+vmKMBKa21dp54uM=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>my library</td>\n",
       "      <td>Local playlist more</td>\n",
       "      <td>local-library</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7</td>\n",
       "      <td>20160219</td>\n",
       "      <td>20170918</td>\n",
       "      <td>224130</td>\n",
       "      <td>458</td>\n",
       "      <td>梁文音 (Rachel Liang)</td>\n",
       "      <td>Qi Zheng Zhang</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>愛其實很殘忍</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1035059</td>\n",
       "      <td>08rvvaaab7dM7h78GC4SphLkUCSXPxpu6sY+k8aLUO4=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>my library</td>\n",
       "      <td>Local playlist more</td>\n",
       "      <td>local-library</td>\n",
       "      <td>5</td>\n",
       "      <td>29</td>\n",
       "      <td>female</td>\n",
       "      <td>7</td>\n",
       "      <td>20120105</td>\n",
       "      <td>20171113</td>\n",
       "      <td>224130</td>\n",
       "      <td>458</td>\n",
       "      <td>梁文音 (Rachel Liang)</td>\n",
       "      <td>Qi Zheng Zhang</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>愛其實很殘忍</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>89968</td>\n",
       "      <td>1NvrMNDUcvfqOIjhim8BgdK23znMzGwAO84W+qKs6dw=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>my library</td>\n",
       "      <td>Local playlist more</td>\n",
       "      <td>local-library</td>\n",
       "      <td>14</td>\n",
       "      <td>20</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>20130908</td>\n",
       "      <td>20171003</td>\n",
       "      <td>224130</td>\n",
       "      <td>458</td>\n",
       "      <td>梁文音 (Rachel Liang)</td>\n",
       "      <td>Qi Zheng Zhang</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>愛其實很殘忍</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>972394</td>\n",
       "      <td>GfSXhTVP3oj7h0545L/5xh6jD+7edQ7AH0iprl7dYbc=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>my library</td>\n",
       "      <td>Local playlist more</td>\n",
       "      <td>local-library</td>\n",
       "      <td>22</td>\n",
       "      <td>22</td>\n",
       "      <td>male</td>\n",
       "      <td>7</td>\n",
       "      <td>20131011</td>\n",
       "      <td>20170911</td>\n",
       "      <td>224130</td>\n",
       "      <td>458</td>\n",
       "      <td>梁文音 (Rachel Liang)</td>\n",
       "      <td>Qi Zheng Zhang</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>愛其實很殘忍</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2194574</td>\n",
       "      <td>HkWEvfQyrb5Lve8X3B7HkCEkDFW8qFy/9kWFb4QbM5k=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>discover</td>\n",
       "      <td>Discover Feature</td>\n",
       "      <td>song-based-playlist</td>\n",
       "      <td>15</td>\n",
       "      <td>26</td>\n",
       "      <td>female</td>\n",
       "      <td>9</td>\n",
       "      <td>20060616</td>\n",
       "      <td>20180516</td>\n",
       "      <td>224130</td>\n",
       "      <td>458</td>\n",
       "      <td>梁文音 (Rachel Liang)</td>\n",
       "      <td>Qi Zheng Zhang</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>愛其實很殘忍</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        id                                          msno  \\\n",
       "0        0  V8ruy7SGk7tDm3zA51DPpn6qutt+vmKMBKa21dp54uM=   \n",
       "1  1035059  08rvvaaab7dM7h78GC4SphLkUCSXPxpu6sY+k8aLUO4=   \n",
       "2    89968  1NvrMNDUcvfqOIjhim8BgdK23znMzGwAO84W+qKs6dw=   \n",
       "3   972394  GfSXhTVP3oj7h0545L/5xh6jD+7edQ7AH0iprl7dYbc=   \n",
       "4  2194574  HkWEvfQyrb5Lve8X3B7HkCEkDFW8qFy/9kWFb4QbM5k=   \n",
       "\n",
       "                                        song_id source_system_tab  \\\n",
       "0  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=        my library   \n",
       "1  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=        my library   \n",
       "2  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=        my library   \n",
       "3  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=        my library   \n",
       "4  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=          discover   \n",
       "\n",
       "    source_screen_name          source_type  city  bd  gender  registered_via  \\\n",
       "0  Local playlist more        local-library     1   0     NaN               7   \n",
       "1  Local playlist more        local-library     5  29  female               7   \n",
       "2  Local playlist more        local-library    14  20     NaN               3   \n",
       "3  Local playlist more        local-library    22  22    male               7   \n",
       "4     Discover Feature  song-based-playlist    15  26  female               9   \n",
       "\n",
       "   registration_init_time  expiration_date  song_length genre_ids  \\\n",
       "0                20160219         20170918       224130       458   \n",
       "1                20120105         20171113       224130       458   \n",
       "2                20130908         20171003       224130       458   \n",
       "3                20131011         20170911       224130       458   \n",
       "4                20060616         20180516       224130       458   \n",
       "\n",
       "          artist_name        composer lyricist  language    name          isrc  \n",
       "0  梁文音 (Rachel Liang)  Qi Zheng Zhang      NaN       3.0  愛其實很殘忍  TWUM71400047  \n",
       "1  梁文音 (Rachel Liang)  Qi Zheng Zhang      NaN       3.0  愛其實很殘忍  TWUM71400047  \n",
       "2  梁文音 (Rachel Liang)  Qi Zheng Zhang      NaN       3.0  愛其實很殘忍  TWUM71400047  \n",
       "3  梁文音 (Rachel Liang)  Qi Zheng Zhang      NaN       3.0  愛其實很殘忍  TWUM71400047  \n",
       "4  梁文音 (Rachel Liang)  Qi Zheng Zhang      NaN       3.0  愛其實很殘忍  TWUM71400047  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 2555994 entries, 0 to 2555993\n",
      "Data columns (total 20 columns):\n",
      "id                        int64\n",
      "msno                      object\n",
      "song_id                   object\n",
      "source_system_tab         object\n",
      "source_screen_name        object\n",
      "source_type               object\n",
      "city                      int64\n",
      "bd                        int64\n",
      "gender                    object\n",
      "registered_via            int64\n",
      "registration_init_time    int64\n",
      "expiration_date           int64\n",
      "song_length               int64\n",
      "genre_ids                 object\n",
      "artist_name               object\n",
      "composer                  object\n",
      "lyricist                  object\n",
      "language                  float64\n",
      "name                      object\n",
      "isrc                      object\n",
      "dtypes: float64(1), int64(7), object(12)\n",
      "memory usage: 409.5+ MB\n"
     ]
    }
   ],
   "source": [
    "data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "id                              0\n",
       "msno                            0\n",
       "song_id                         0\n",
       "source_system_tab            8441\n",
       "source_screen_name         162845\n",
       "source_type                  7296\n",
       "city                            0\n",
       "bd                              0\n",
       "gender                    1051881\n",
       "registered_via                  0\n",
       "registration_init_time          0\n",
       "expiration_date                 0\n",
       "song_length                     0\n",
       "genre_ids                   42070\n",
       "artist_name                     0\n",
       "composer                   618960\n",
       "lyricist                  1224246\n",
       "language                       17\n",
       "name                            7\n",
       "isrc                       195869\n",
       "dtype: int64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.apply(lambda x: sum(x.isnull()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 类别型特征分布情况"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"\\n#train_song.apply(lambda x: sum(x.isnull))\\ncat_features=['msno','song_id','source_system_tab','source_screen_name','source_type']\\nfor col in cat_features:\\n    num_vlaules = len(test_data[col].unique())\\n    print('\\n%s属性有%d的不同取值，各取值及其出现的次数\\n'% (col,num_vlaules))\\n    print(test_data[col].value_counts()) \\n\""
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "#train_song.apply(lambda x: sum(x.isnull))\n",
    "cat_features=['msno','song_id','source_system_tab','source_screen_name','source_type']\n",
    "for col in cat_features:\n",
    "    num_vlaules = len(test_data[col].unique())\n",
    "    print('\\n%s属性有%d的不同取值，各取值及其出现的次数\\n'% (col,num_vlaules))\n",
    "    print(test_data[col].value_counts()) \n",
    "'''"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### msno，song_id\n",
    "LightGBM对类别特征建立直方图，当特征取值数目超过max_bin,会去掉样本数目少的类别\n",
    "统计该特征下每一种离散出现的次数，并从高到低排序，并过滤掉出现次数较少的特征值，\n",
    "然后为每一个特征值，建立一个bin容器，对于在bin容器内出现次数较少的特征值直接过滤掉\n",
    "，不建立bin容器"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\ncat_features =[\\'msno\\',\\'song_id\\']\\nrare_thresholds = [10,100]\\nj=0\\nfor col in cat_features:\\n    #每个取值的样本数目\\n    #print(\\'col\\',col)\\n    value_counts_col=test_data[col].value_counts(dropna=False)\\n    #print(\\'value_counts_col\\',value_counts_col)\\n    #样本数目小于阈值的取值为稀有取值\\n    #print(\\'j=\\',j)  \\n    #print(\\'arej=\\',rare_thresholds[j])  \\n       \\n    rare_threshold = rare_thresholds[j]\\n    #print(\\'rare_threshold\\',rare_threshold)    \\n    value_counts_rare = list(value_counts_col[value_counts_col< rare_threshold].index)\\n    #稀有值合并为others\\n    rare_index = test_data[col].isin(value_counts_rare)\\n    test_data.loc[test_data[col].isin(value_counts_rare),col]=\"Others\"\\n    j = j+1\\n'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "cat_features =['msno','song_id']\n",
    "rare_thresholds = [10,100]\n",
    "j=0\n",
    "for col in cat_features:\n",
    "    #每个取值的样本数目\n",
    "    #print('col',col)\n",
    "    value_counts_col=test_data[col].value_counts(dropna=False)\n",
    "    #print('value_counts_col',value_counts_col)\n",
    "    #样本数目小于阈值的取值为稀有取值\n",
    "    #print('j=',j)  \n",
    "    #print('arej=',rare_thresholds[j])  \n",
    "       \n",
    "    rare_threshold = rare_thresholds[j]\n",
    "    #print('rare_threshold',rare_threshold)    \n",
    "    value_counts_rare = list(value_counts_col[value_counts_col< rare_threshold].index)\n",
    "    #稀有值合并为others\n",
    "    rare_index = test_data[col].isin(value_counts_rare)\n",
    "    test_data.loc[test_data[col].isin(value_counts_rare),col]=\"Others\"\n",
    "    j = j+1\n",
    "'''"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "类别特征先编码成数值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "source_system_tab <class 'str'>\n",
      "source_screen_name <class 'str'>\n",
      "source_type <class 'str'>\n",
      "gender <class 'str'>\n",
      "genre_ids <class 'str'>\n",
      "artist_name <class 'str'>\n",
      "composer <class 'str'>\n",
      "lyricist <class 'str'>\n",
      "name <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "from sklearn.preprocessing import LabelEncoder\n",
    "le = LabelEncoder()\n",
    "feats_to_encode=['source_system_tab','source_screen_name','source_type','gender','genre_ids','artist_name','composer','lyricist','name']\n",
    "for col in feats_to_encode:\n",
    "    print(col,type(col))\n",
    "    data[col] = le.fit_transform(data[col].astype(str))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### #最终数据样式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>msno</th>\n",
       "      <th>song_id</th>\n",
       "      <th>source_system_tab</th>\n",
       "      <th>source_screen_name</th>\n",
       "      <th>source_type</th>\n",
       "      <th>city</th>\n",
       "      <th>bd</th>\n",
       "      <th>gender</th>\n",
       "      <th>registered_via</th>\n",
       "      <th>registration_init_time</th>\n",
       "      <th>expiration_date</th>\n",
       "      <th>song_length</th>\n",
       "      <th>genre_ids</th>\n",
       "      <th>artist_name</th>\n",
       "      <th>composer</th>\n",
       "      <th>lyricist</th>\n",
       "      <th>language</th>\n",
       "      <th>name</th>\n",
       "      <th>isrc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>V8ruy7SGk7tDm3zA51DPpn6qutt+vmKMBKa21dp54uM=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>20160219</td>\n",
       "      <td>20170918</td>\n",
       "      <td>224130</td>\n",
       "      <td>300</td>\n",
       "      <td>24882</td>\n",
       "      <td>33204</td>\n",
       "      <td>16297</td>\n",
       "      <td>3.0</td>\n",
       "      <td>124178</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1035059</td>\n",
       "      <td>08rvvaaab7dM7h78GC4SphLkUCSXPxpu6sY+k8aLUO4=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>29</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>20120105</td>\n",
       "      <td>20171113</td>\n",
       "      <td>224130</td>\n",
       "      <td>300</td>\n",
       "      <td>24882</td>\n",
       "      <td>33204</td>\n",
       "      <td>16297</td>\n",
       "      <td>3.0</td>\n",
       "      <td>124178</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>89968</td>\n",
       "      <td>1NvrMNDUcvfqOIjhim8BgdK23znMzGwAO84W+qKs6dw=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "      <td>14</td>\n",
       "      <td>20</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>20130908</td>\n",
       "      <td>20171003</td>\n",
       "      <td>224130</td>\n",
       "      <td>300</td>\n",
       "      <td>24882</td>\n",
       "      <td>33204</td>\n",
       "      <td>16297</td>\n",
       "      <td>3.0</td>\n",
       "      <td>124178</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>972394</td>\n",
       "      <td>GfSXhTVP3oj7h0545L/5xh6jD+7edQ7AH0iprl7dYbc=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "      <td>22</td>\n",
       "      <td>22</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>20131011</td>\n",
       "      <td>20170911</td>\n",
       "      <td>224130</td>\n",
       "      <td>300</td>\n",
       "      <td>24882</td>\n",
       "      <td>33204</td>\n",
       "      <td>16297</td>\n",
       "      <td>3.0</td>\n",
       "      <td>124178</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2194574</td>\n",
       "      <td>HkWEvfQyrb5Lve8X3B7HkCEkDFW8qFy/9kWFb4QbM5k=</td>\n",
       "      <td>WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>15</td>\n",
       "      <td>26</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>20060616</td>\n",
       "      <td>20180516</td>\n",
       "      <td>224130</td>\n",
       "      <td>300</td>\n",
       "      <td>24882</td>\n",
       "      <td>33204</td>\n",
       "      <td>16297</td>\n",
       "      <td>3.0</td>\n",
       "      <td>124178</td>\n",
       "      <td>TWUM71400047</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        id                                          msno  \\\n",
       "0        0  V8ruy7SGk7tDm3zA51DPpn6qutt+vmKMBKa21dp54uM=   \n",
       "1  1035059  08rvvaaab7dM7h78GC4SphLkUCSXPxpu6sY+k8aLUO4=   \n",
       "2    89968  1NvrMNDUcvfqOIjhim8BgdK23znMzGwAO84W+qKs6dw=   \n",
       "3   972394  GfSXhTVP3oj7h0545L/5xh6jD+7edQ7AH0iprl7dYbc=   \n",
       "4  2194574  HkWEvfQyrb5Lve8X3B7HkCEkDFW8qFy/9kWFb4QbM5k=   \n",
       "\n",
       "                                        song_id  source_system_tab  \\\n",
       "0  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=                  3   \n",
       "1  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=                  3   \n",
       "2  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=                  3   \n",
       "3  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=                  3   \n",
       "4  WmHKgKMlp1lQMecNdNvDMkvIycZYHnFwDT72I5sIssc=                  0   \n",
       "\n",
       "   source_screen_name  source_type  city  bd  gender  registered_via  \\\n",
       "0                   8            3     1   0       2               7   \n",
       "1                   8            3     5  29       0               7   \n",
       "2                   8            3    14  20       2               3   \n",
       "3                   8            3    22  22       1               7   \n",
       "4                   4           10    15  26       0               9   \n",
       "\n",
       "   registration_init_time  expiration_date  song_length  genre_ids  \\\n",
       "0                20160219         20170918       224130        300   \n",
       "1                20120105         20171113       224130        300   \n",
       "2                20130908         20171003       224130        300   \n",
       "3                20131011         20170911       224130        300   \n",
       "4                20060616         20180516       224130        300   \n",
       "\n",
       "   artist_name  composer  lyricist  language    name          isrc  \n",
       "0        24882     33204     16297       3.0  124178  TWUM71400047  \n",
       "1        24882     33204     16297       3.0  124178  TWUM71400047  \n",
       "2        24882     33204     16297       3.0  124178  TWUM71400047  \n",
       "3        24882     33204     16297       3.0  124178  TWUM71400047  \n",
       "4        24882     33204     16297       3.0  124178  TWUM71400047  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "data.to_csv(dpath +'FE_test.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
